import 'dart:ui';

import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
  RadioDemo({Key? key}) : super(key: key);

  @override
  State<RadioDemo> createState() => _RadioDemoState();
}

class _RadioDemoState extends State<RadioDemo> {
  var sex = 1;
  bool flag = true;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Radio"),
      ),
      body: Padding(
        padding: EdgeInsets.all(20),
        child: Column(
          children: <Widget>[
            Row(children: <Widget>[
              // Text("男"),
              // Radio(
              //     value: 1,
              //     groupValue: this.sex,
              //     onChanged: (v) {
              //       print(v);
              //       setState(() {
              //         this.sex = v as int;
              //       });
              //     }),
              // Text("女"),
              // Radio(
              //     value: 2,
              //     groupValue: this.sex,
              //     onChanged: (v) {
              //       print(v);
              //       setState(() {
              //         this.sex = v as int;
              //       });
              //     }),
              // Row(
              //   children: <Widget>[Text("${this.sex == 1 ? "男" : "女"}")],
              // ),

              Column(
                children: <Widget>[
                  // RadioListTile(
                  //     value: 1,
                  //     groupValue: this.sex,
                  //     onChanged: (v) {
                  //       setState(() {
                  //         this.sex = v as int;
                  //       });
                  //     },
                  //     title: Text("标题"),
                  //     subtitle: Text("这是一个二级标题"),
                  //     secondary: Icon(Icons.help)),
                  // RadioListTile(
                  //   value: 2,
                  //   groupValue: this.sex,
                  //   onChanged: (v) {
                  //     setState(() {
                  //       this.sex = v as int;
                  //     });
                  //   },
                  //   title: Text("标题"),
                  //   subtitle: Text("这是一个二级标题"),
                  //   secondary: Image.network(
                  //       "https://pic.netbian.com/uploads/allimg/220406/001517-1649175317d3b0.jpg"),
                  //   selected: this.sex == 2,
                  // ),
                  Switch(
                      value: this.flag,
                      onChanged: (v) {
                        setState(() {
                          print(v);
                          this.flag = v;
                        });
                      })
                ],
              )
            ])
          ],
        ),
      ),
    );
  }
}
